package com.db
import java.sql.*;
import groovy.sql.Sql
class MysqlDb {
	
	static main(args) {
		
		
		def sql = Sql.newInstance("jdbc:mysql://127.0.0.1:3306/test", "root","aaaaaaaa", "com.mysql.jdbc.Driver")
		
//		sql.execute """
//		CREATE  TABLE `test`.`test` (
//
//		  `id` INT NOT NULL ,
//		
//		  `name` VARCHAR(45) NULL ,
//		
//		  `psw` VARCHAR(45) NULL ,
//		
//		  PRIMARY KEY (`id`) )
//		
//		ENGINE = MEMORY
//		
//		DEFAULT CHARACTER SET = utf8;
//		"""
	 
		
		def dirName ="d:\\";
		def fileType=".java"
		
		def dir = new File(dirName)
		if (dir.isDirectory()) {
			dir.eachFileRecurse {
				String a = it ;
				if(a.endsWith(fileType)){
					println ("无题"+a);
					//com.util.net.EmailGroovy.sendMyEmail("blogmail@188.com","无题","",a);
					sql.execute "insert into test (name,psw) values('"+a+"','c')"
				}
			}
		}
		
	 
		
		sql.close()
	}
}
